<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/12
 * Time: 22:32
 */

namespace app\api\controller;

use app\common\lib\Aes;
use app\common\lib\exception\ApiException;
use think\Controller;

class Test extends Common
{

    public function index(){
        return [
            'Chen Ke',
            'Xie LeiLei'
        ];
    }

    public function update( $id = 0){
        $data = input('put.');
        return [
            'data' => $data,
        ];
    }

    public function delete($id = 0){
        return $id;
    }

    public function save(){

        $data = input('post.');
        if($data['mt'] != 1){
            throw new ApiException('您提交的数据不合法', 403);
        }

        $aesStr = (new Aes())->encrypt(json_encode(input('post.')));

        echo $aesStr.PHP_EOL;
        echo (new Aes())->decrypt($aesStr).PHP_EOL;

        return show(1, 'OK', (new Aes())->encrypt(json_encode(input('post.'))), 201);
    }

}